extension DoublePriceString on double {
  /// 转换为用于界面显示的价格字符串。
  ///
  /// ```dart
  /// (1.0).toPriceString() // '1'
  /// (1.2).toPriceString() // '1.20'
  /// (1.254).toPriceString() // '1.25'
  /// ```
  String toPriceString() {
    final price = this;
    final nPrice = price.floorToDouble();
    if (price - nPrice == 0.0) {
      return price.toInt().toString();
    }
    return price.toStringAsFixed(2);
  }
}